/**
 * 新增履历
 * 工程项目名称：青州市民卡核心系统
 * 方法名：库存管理模块
 * 版本： ver 1.0  初版
 * 创建日期：20190319
 * 创建人：惠国磊
 */

//获取返回的制卡文件信息
function getResponseFilesInfo(json){
	var content="";
	var item = json.dPage;
	var activeUser = json.activeUser;
		var numPerPage=item.numPerPage;
	//	alert("page==>"+numPerPage);
		var currentPage=item.currentPage;
		var totalCount=item.totalCount;
		var pageCount=item.pageCount;
		var onePageCount = [numPerPage*[currentPage-1]];
		var list=item.list;
		var userNo=activeUser.userNo;
		var branchNo=activeUser.branchNo;
	//	alert("page==>"+numPerPage+"#"+currentPage+"#"+currentPage);
		$("input[name='userNoQC']").val(userNo);
		$("input[name='branchNoQC']").val(branchNo);
		console.log("length====>"+list.length);
		if(list.length==0){
			content+="<tr><td colspan='8' align='center' >未查询到数据</td></tr>"
		}else{
			for(var i=0;i<list.length;i++){
				var value=list[i].responseCompanyNo+"\\"+list[i].responseFileNo;
				//alert("checkBox-value==>"+value);
				content+="<tr align='center'>"
					     +"<td><input name='responseFiletasked' onclick='test(this)' value="+value+" type='checkbox'></td>"
					     +"<td>"+eval(i+1+parseInt(onePageCount))+"</td>"
					     +"<td>"+"<a class='linkStyle' class='linkStyle' href='inventoryIncmoingMagOfCenter/getResponseFileDetail' target='dialog' rel='文件详细信息' max='true' param='"+encodeURI(list[i].responseCompanyNo)+"\\"+list[i].responseFileNo+"'>"+list[i].responseFileNo+"</a></td>"
					     +"<td>"+list[i].responseCompanyNo+"</td>"
					     +"</tr>" 
					     //inventorymanagement/getResponseFileDetail
					     //
			}
			
		}
		//console.log("responseFileDetail=>"+$("#responseFileDetail").html());
		$("#responseFileDetail").html(content);
		$("input[name='numPerPage']").val(numPerPage);
		$("input[name='pageNum']").val(currentPage); 
		$("#totalCountByIM").text("条，共"+totalCount+"条");
		$("#paginationByQueryPurchaseTask").addClass("pagination").attr("targetType","navTab").attr("totalCount",totalCount).attr("numPerPage",numPerPage).attr("pageNumShown","10").attr("currentPage",currentPage).attr("rel","responseFileDetail").attr("callback","getResponseFilesInfo");
		
		$("div.pagination").each(function(n,item){
			var $this = $(this);
			$this.pagination({
				targetType:"navTab",
				rel:"responseFileDetail",
				totalCount:totalCount,
				numPerPage:numPerPage,
				pageNumShown:10,
				currentPage:currentPage,
				callback:getResponseFilesInfo
			});
		});
		
		var $p = $("#ByPurchaseQuery");
		initUI($p);
};

//加载文件详细信息
function loadDetailInfo(json){
	var content="";
	var item = json.detailMap;
	
	var company = item.company;
	var detailList = item.fileDetail;
	var QBJMFlag = item.cardTypeFlag;
	if(QBJMFlag=="QJMK"){
		
		var allAmount = item.requireAmount;
		var sumAount = item.successAmount;
		var faAmount = allAmount-sumAount;
		//卡产品名称
		var cardPName = item.cardPName;
		var flag = ["成功","失败"];
		//alert("列表长度==>"+detailList.length);
		$("input[name='responseFileNo']").val(detailList[0].makeCardFileName);
		$("input[name='cardCompany']").val(company);
		$("input[name='responseCardTotal']").val(allAmount);
		$("input[name='successCardAmount']").val(sumAount);
		$("input[name='failureCardAmount']").val(faAmount);
		$("input[name='cardPName']").val(cardPName);
		for(var i=0;i<detailList.length;i++){
			content+="<tr align='center'>"
			     +"<td width='2%'>"+[i+1]+"</td>"
			     +"<td width='5%'>"+detailList[i].makeCardFileName+"</td>"
			     +"<td width='5%'>"+detailList[i].citizenCardNo+"</td>"
			     +"<td width='5%'>"+flag[detailList[i].resultOfMakeCd]+"</td>"
			     +"<td width='5%'>"+detailList[i].causeOfFailure+"</td>"
			     +"</tr>" 
		}
		$("#responseDetail").html(content);
		
		var $p = $("#ByResponseDetail");
		initUI($p);
	}
	if(QBJMFlag=="QBJM"){
		var allAmount = detailList.totalAmount;
		var successAmount = detailList.successAmount;
		var failAmount = detailList.failAmount;
		var makeCardFileName = detailList.makeCardFileName;
		var failCardNos = detailList.failCards;
		var batchMakeNo = detailList.batchMakeNo;
		var cardTaskNo = detailList.cardTaskNo;
//		console.log("allAmount=="+allAmount+"==successAmount=="+successAmount+
//				"==failAmount=="+failAmount+"==makeCardFileName=="+makeCardFileName+"==failCardNos=="+
//				failCardNos+"==batchMakeNo=="+batchMakeNo+"==cardTaskNo=="+cardTaskNo);
		var startNo = item.startNo;
		var endNo = item.endNo;
		var cardPName = item.cardPName;
	//	console.log("startNo==>"+startNo+"==endNo==>"+endNo);
		
		//
		$("input[name='responseFileNo']").val(makeCardFileName);
		$("input[name='cardCompany']").val(company);
		$("input[name='responseCardTotal']").val(allAmount);
		$("input[name='successCardAmount']").val(successAmount);
		$("input[name='failureCardAmount']").val(failAmount);
		$("input[name='cardPName']").val(cardPName);
		
		$("#startNo").find("div").html("起始卡号");
		$("#endNo").find("div").html("终止卡号");
		$("#failNo").find("div").html("失败卡号");
		content+="<tr align='center'>"
		     +"<td width='2%'>"+1+"</td>"
		     +"<td width='5%'>"+makeCardFileName+"</td>"
		     +"<td width='5%'>"+startNo+"</td>"
		     +"<td width='5%'>"+endNo+"</td>"
		     +"<td width='5%'>"+failCardNos+"</td>"
		     +"</tr>"
		$("#responseDetail").html(content);
		
		var $p = $("#ByResponseDetail");
		initUI($p);
	}
}

//加载入库登记画面信息
function getIncomingDetail(json){
	var content="";
	var item = json.incomingDetail;
	var activeUser = json.activeUser;
	var userNo=activeUser.userNo;
	var branchNo=activeUser.branchNo;
	//鱼洲杰修改
	$("input[name='empNoByPCR']").val(userNo);
	$("input[name='branchNoByPurchaseRgByPCR']").val(branchNo);
	//alert("列表长度===>"+item.length);
	//制卡要求总数量
	var requireTotalAmount=0;
	//制卡成功总数量
	var successTotalAmount=0;
	//序号变量
	//var no = 1;
	for(var i=0;i<item.length;i++){
			var subItem = item[i];
			var company = subItem.company;
			var physicType = subItem.cardPhysicType;
			//alert("company==>"+company);
			//每个文件的所有卡号和制卡结果的键值对
			var cardResult ;
			var requireAmount = 0;
			var successAmount = 0;
			var cardTypeFlag = subItem.cardTypeFlag;
			var requireAmount = subItem.requireAmount;
			requireTotalAmount = parseInt(requireTotalAmount) + parseInt(requireAmount);
			var successAmount = subItem.successAmount;
			successTotalAmount = parseInt(successTotalAmount) + parseInt(successAmount);
			var cardPName = "";
			var cardPCode = "";
			var makeCardFileName = "";
			var batchMakeNo = "";
			var fielInfoObject = subItem.fileDetail;
			//获取所有的卡号
			var citizenCardNo = "";
			//所有卡号的结果值
			var cardResult = "";
			var startNo = "";
	
			//终止号码段
			var endNo = "";
			var cardTaskNoHtml = "";
			
			var cityCode = "";
			var untouchChipNo = "";
			var untouchPin = "";
			var cardSerialNo = "";
			cardPName = subItem.cardPName;
			cardPCode = subItem.cardPCode;
					
			
			if(cardTypeFlag=="QJMK"){
				cardResult = subItem.cardResult;
				
				makeCardFileName = fielInfoObject[0].makeCardFileName;
				batchMakeNo = fielInfoObject[0].batchMakeNo;
				for(var j=0;j<fielInfoObject.length;j++){
					if(j==0){
						citizenCardNo = fielInfoObject[j].citizenCardNo;
						cardResult = fielInfoObject[j].resultOfMakeCd;
						//卡片序列号
						cardSerialNo = fielInfoObject[j].cardSerialNo;
						//非接触芯片号
						untouchChipNo = fielInfoObject[j].untouchChipNo;
						//非接触pin
						untouchPin = fielInfoObject[j].untouchPin;
						//城市代码
						cityCode = fielInfoObject[j].cityCode;
					}
					if(j>0){
						citizenCardNo = citizenCardNo +"#"+ fielInfoObject[j].citizenCardNo;
						cardResult = cardResult +"#"+ fielInfoObject[j].resultOfMakeCd;
						cardSerialNo = cardSerialNo +"#"+ fielInfoObject[j].cardSerialNo;
						untouchChipNo = untouchChipNo +"#"+ fielInfoObject[j].untouchChipNo;
						untouchPin = untouchPin +"#"+ fielInfoObject[j].untouchPin;
						cityCode = cityCode +"#"+ fielInfoObject[j].cityCode;
					}
				}
				cardTaskNoHtml = "<td style='display:none;'><input size = '5' name='cardTaskNoByIncomingReg' style='border:0;' value='"+"QJMK"+"'/></td>"
			}	
			if(cardTypeFlag=="QBJM"){
				makeCardFileName = "";
				makeCardFileName = fielInfoObject.makeCardFileName;
				batchMakeNo = fielInfoObject.batchMakeNo;
				startNo = subItem.startNo;
				endNo = subItem.endNo;
				citizenCardNo = startNo+"~"+endNo;
				cardResult = fielInfoObject.failCards;
				//如果制卡返回文件种的结果又失败卡号的，把，转换成#
				if(!cardResult){
					cardResult = "no";
				}
				else if(cardResult.indexOf(",")>0){
					cardResult = cardResult.replace(/,/g, '#');
				}
				cardTaskNoHtml = "<td style='display:none;'><input size = '5' name='cardTaskNoByIncomingReg' style='border:0;' value='"+fielInfoObject.cardTaskNo+"'/></td>"
					
			}			
			/*登记页面赋值*/
			content+="<tr align='center'>"
				     +"<td>"+[i+1]+"</td>"
				     +"<td><input name='cardPName' size='15' style='border:0;text-align:center;' readonly='readonly' unselectable='on' value='"+cardPName+"'/></td>"
				     +"<td><input name='batchMakeNo' size='15' style='border:0;text-align:center;' readonly='readonly' unselectable='on' value='"+batchMakeNo+"'/></td>"
				     +"<td><input name='company' size='15' style='border:0;text-align:center;' readonly='readonly' unselectable='on' value='"+company+"'/></td>"
				     +"<td><input name='successAmount' size='5' style='border:0;text-align:center;' readonly='readonly' unselectable='on' value='"+successAmount+"'/></td>"
				     +"<td style='display:none;'><input size = '5' name='makeCardFileName' style='border:0;' value='"+makeCardFileName+"'/></td>"
				     +"<td style='display:none;'><input size = '5' name='citizenCardNo' style='border:0;' value='"+citizenCardNo+"'/></td>"
				     +"<td style='display:none;'><input size = '5' name='cardResult' style='border:0;' value='"+cardResult+"'/></td>"
				     +"<td style='display:none;'><input size = '5' name='cardPCodeByIncomingReg' style='border:0;' value='"+cardPCode+"'/></td>"
				     +"<td style='display:none;'><input size = '5' name='cardPhysicTypeByIncomingReg' style='border:0;' value='"+physicType+"'/></td>"
				     +"<td style='display:none;'><input size = '5' name='cardSerialNoByIncomingReg' style='border:0;' value='"+cardSerialNo+"'/></td>"
				     +"<td style='display:none;'><input size = '5' name='untouchChipNoByIncomingReg' style='border:0;' value='"+untouchChipNo+"'/></td>"
				     +"<td style='display:none;'><input size = '5' name='untouchPinByIncomingReg' style='border:0;' value='"+untouchPin+"'/></td>"
				     +"<td style='display:none;'><input size = '5' name='cityCodeByIncomingReg' style='border:0;' value='"+cityCode+"'/></td>"
				     +cardTaskNoHtml
				     +"</tr>" 
		}
		
		//获取库存单号
	/*	var storageNo = item[item.length-1].storageNo;
		//alert("storageNo==>"+storageNo);
		$("input[name='storageNoByPCR']").val(storageNo);*/
		$("#tbodyByIncomingDetail").html(content);
		$("#tbodyByIncomingDetail").initUI();
		$("input[name='totalAmountByPCR']").val(successTotalAmount);	
		var $p = $("#purchaseCardReg");
		initUI($p);
}

//获取配送信息
function getDistributionDetail(json){
	var content="";
	//$("#distributionTask").html();
	var item = json.taskDPage;
	var totalCount=item.totalCount;
	var numPerPage=item.numPerPage;
	//alert("page==>"+numPerPage);
	var currentPage=item.currentPage;
	var pageCount=item.pageCount
	var onePageCount = [numPerPage*[currentPage-1]];
	var list=item.list;
	var activeUser = json.activeUser;
	var userNo=activeUser.userNo;
	var branchNo=activeUser.branchNo;
	$("input[name='operatorNo']").val(userNo);
	$("input[name='branchNo']").val(branchNo);
	//alert("cardpName==>"+list[i].tasksGeneTime);
	//var taskGeTime = list[1].tasksGeTime;
	//alert("任务生成日期的对象类型==>"+typeof(taskGeTime));
	//alert("list==>"+list.length);
	if(list.length==0){
		content+="<tr><td colspan='8' align='center' >未查询到数据</td></tr>"
	}else{
		for(var i=0;i<list.length;i++){
			var value=list[i].cardDefinition.cardpName+"#"+list[i].applyBranch+"#"+list[i].cardTaskNo+
			          "#"+list[i].taskName+"#"+list[i].recordNum+"#"+list[i].stockDetail.amount+
			          "#"+list[i].tasksGeTime+"#"+list[i].stockDetail.lstInDate+"#"+list[i].cardpCode+
			          //20180528 惠国磊  再清单中加入制卡商和制卡号
			          "#"+list[i].batchMarkerNo+"#"+list[i].companyNo+"#"+list[i].applyBranchNo;
			//alert("checkBox-value==>"+value);
			//alert("cardpName==>"+list[i].cardDefinition.cardpName);
			
			//判断日期类型
			
			
			content+="<tr align='center'>"
				     +"<td><input name='distributionTasked' onclick='test(this)' value="+value+" type='checkbox'></td>"
				     +"<td>"+eval(i+1+parseInt(onePageCount))+"</td>"
				     +"<td>"+list[i].cardDefinition.cardpName+"</td>"
				     +"<td>"+list[i].applyBranch+"</td>"
				     +"<td>"+list[i].cardTaskNo+"</td>"
				     +"<td>"+list[i].taskName+"</td>"
				     +"<td>"+list[i].recordNum+"</td>"
				     +"<td>"+list[i].stockDetail.amount+"</td>"
				     +"<td>"+list[i].tasksGeTime+"</td>"
				     +"<td>"+list[i].stockDetail.lstInDate+"</td>"
				     +"<td style='display:none;'>"+list[i].cardpCode+"</td>"
				     +"<td style='display:none;'>"+list[i].batchMarkerNo+"</td>"
				     +"<td style='display:none;'>"+list[i].companyNo+"</td>"
				     +"</tr>" 
				     //inventorymanagement/getResponseFileDetail
				     //
		}
		
	}
	$("#distributionTask").html(content);
	$("input[name='numPerPage']").val(numPerPage);
	$("input[name='pageNum']").val(currentPage); 
	$("input[name='pageCount']").val(pageCount);
	$("#totalCountByDT").text("条，共"+totalCount+"条");
	/*var pagination="<a href='#' onclick='previous()' id='previous' >上一页  </a><a href='#' onclick='next()' id='next'> 下一页</a><span>当前第"+cuurentPage+"页，共"+pageCount+"页</span>";
	$("#paginationByDT").html(pagination);*/
	$("#paginationByDT").addClass("pagination").attr("targetType","navTab").attr("totalCount",totalCount).attr("numPerPage",numPerPage).attr("pageNumShown","10").attr("currentPage",currentPage).attr("rel","distributionTask").attr("callback","getDistributionDetail");
	$("div.pagination").each(function(){
		var $this = $(this);
		$this.pagination({
			targetType:"navTab",
			rel:"distributionTask",
			totalCount:totalCount,
			numPerPage:numPerPage,
			pageNumShown:10,
			currentPage:currentPage,
			callback:getDistributionDetail
		});
	});
	var $p = $("#cardDistribution");
	initUI($p);
	//initUI($("#distributionTask"));
}

function getDistributionRegInfo(json){
	//alert("666");
	var content="";
	$("#distributionDetail").html();
	var item = json.activeUser;
	var userNo=item.userNo;
	var branchNo=item.branchNo;
	$("input[name='distributeOperator']").val(userNo);
	$("input[name='distributeBranch']").val(branchNo);
//	var cardPNameList = json.cardPNameList;
//	var cardPNameMap = json.cardPNameMap;
	
	var cardPCodeList = json.cardPCodeList;
//	var storageNo = json.storageNo;
//	var distributeTaskNo = json.distributeTaskNo;
	
	//alert("distributeNo==>"+distributeNo)
	var cardPNameList = json.cardPNameList;
	var cardPhysicTypeList = json.cardPhysicTypeList;
	var cardPNameMap = json.cardPNameMap;
	var cardAmountMap = json.cardAmountMap;
	
	var branchMakeNoList = json.branchMakeNoList;
	var companyList = json.companyList;
	
//	var tableList = json.tableList;
	var distributeAmount = json.distributeAmount;
	var applyBranch = json.applyBranch;
	var applyBranchNo = json.applyBranchNo;
	console.log("applyBranchNo==>"+applyBranchNo);
	//alert("applyBranch==>"+applyBranch);
	var distributeDate = json.distributeDate;
	var taskNoList = json.taskNoList;
	console.log("tasknolist===>"+taskNoList);
	console.log("taskNolist的长度==>"+taskNoList.length);
	//alert("distributeDate==>"+distributeDate);
	$("input[name='receiveBranch']").val(applyBranch);
	$("input[name='distributeDate']").val(distributeDate);
	$("input[name='distributeAmount']").val(distributeAmount);
	//$("input[name='storageNoByDis']").val(storageNo);
//	$("input[name='distributeTaskNoByDis']").val(distributeTaskNo);
	$("input[name='applyBranchNoByDis']").val(applyBranchNo);
	//alert("查询结果集的长度==>"+tableList.length);
	for(var i=0;i<taskNoList.length;i++){
		var cardTaskNo = taskNoList[i];
		//alert("cardTaskNo==>"+cardTaskNo);
		//alert("cardPCode==>"+cardPCode);
		//alert("cardPName==>"+cardAmountMap[cardTaskNo]);
		content+="<tr>"
		     +"<td>"+[i+1]+"</td>"
		     +"<td><input name='cardPNameMap' size='20' style='border:0;text-align:center;' readonly='readonly' unselectable='on' value='"+cardPNameMap[cardTaskNo]+"'/></td>"
		     +"<td><input name='cardTaskNo' size='30' style='border:0; text-align:center;' readonly='readonly' unselectable='on' value='"+cardTaskNo+"'/></td>"
		     +"<td><input name='cardAmount' size='5' style='border:0;text-align:center;' readonly='readonly' unselectable='on' value='"+cardAmountMap[cardTaskNo]+"'/></td>"
		     +"<td style='display:none'><input size='5' name='cardpCode' style='border:0;' readonly='readonly' value='"+cardPCodeList[i]+"'/></td>"
		     +"<td style='display:none'><input size='5' name='cardPhysicTypeByDistribute' style='border:0;' readonly='readonly' value='"+cardPhysicTypeList[i]+"'/></td>"
		     +"<td style='display:none'><input size='5' name='branchMakeNo' style='border:0;' readonly='readonly' value='"+branchMakeNoList[i]+"'/></td>"
		     +"<td style='display:none'><input size='5' name='companyNo' style='border:0;' readonly='readonly' value='"+companyList[i]+"'/></td>"
		     +"</tr>" 
	}
	$("#distributionDetail").html(content);
	var $p = $("#cardDistributionReg");
	initUI($p);
}

//查询网点的废卡信息
function queryDIstributeCardInfo(json){
	// 检索到的数据组成的list
	var distributeList = json.resulList;
	//alert("distributeList的长度==>"+distributeList.length);
	//卡产品代码的map
	var cardProductCode = json.cardProductCode;
	//制卡商代码的map
	var companyCode = json.companyCode;
	
	var content="";
	$("#distributeTasks").html();
	if(distributeList.length==0){
		content+="<tr><td colspan='8' align='center' >未查询到数据</td></tr>";
	}
	if(distributeList.length>0){
		for(var i=0;i<distributeList.length;i++){
			//卡号
			var citizenCardNo = distributeList[i].cardData.citizenCardNo;
			var cardCode = distributeList[i].cardData.cardpCode;
			var cardName = cardProductCode[cardCode];
			var companyNo = distributeList[i].cardTask.companyNo;
			var companyName = companyCode[companyNo];
			var rejectCause = "cause1";
			var validStatus = "无效";
			var rejectCauseCode = "00";
			var cardControlId = distributeList[i].cardControlId;
			var value = citizenCardNo+"#"+encodeURI(cardName)+"#"+encodeURI(validStatus)+
	        "#"+encodeURI(companyName)+"#"+encodeURI(rejectCause)+"#"+cardCode+
	        "#"+companyNo+"#"+rejectCauseCode+"#"+cardControlId;
	        
			/*var value = citizenCardNo+"#"+cardName+"#"+validStatus+
	        "#"+companyName+"#"+rejectCause+"#"+cardCode+
	        "#"+companyNo+"#"+rejectCauseCode;*/
			
			content+="<tr align='center'>"
				 +"<td><input name='distributionTasks' onclick='test(this)' value="+value+" type='checkbox'></td>"
			     +"<td>"+[i+1]+"</td>"
			     +"<td>"+citizenCardNo+"</td>"
			     +"<td>"+cardName+"</td>"
			     +"<td>"+validStatus+"</td>"
			     +"<td>"+companyName+"</td>"
			     +"<td>"+rejectCause+"</td>" 
			     +"<td  style='display:none;'>"+cardCode+"</td>"
			     +"<td  style='display:none;'>"+companyNo+"</td>"
			     +"<td  style='display:none;'>"+rejectCauseCode+"</td>"
			     +"<td  style='display:none;'>"+cardControlId+"</td>"
			     +"</tr>" 
		}
	}
	
	
	$("#distributeTasks").html(content);
	var $p = $("#tocreatedis");
	initUI($p);
	
}

//打开对话框
/*function openDialog(json){
	var url = json.url;
	var rel = json.rel;
	var max = json.max;
	var title = json.title;
	console.log("获得标签的参数是==>"+url+"="+rel+"="+max+"="+title);
	var checkedItems = json.checkedItems;
	var options={"width":"600","height":"500","checkedItems":checkedItems};
	$.pdialog.open("parameterCard/goupdateBusiParamTask",rel, title,options);
}*/




function loadDistributeInfoByReg(json){
	var list = json.distributeDetailList;
//	var storageNo = json.storageNo;
	var curDate = json.curDate;
	var taskNo = json.taskNo;
	var userNo=json.activeUser.userNo;
	var branchNo=json.activeUser.branchNo;
	if(list){
		//alert("返回的list的长度是==>"+list.length);
		$("#cardAmountByReg").val(list.length);
//		$("#storageNoByDistributionByReg").val(storageNo);
		$("#distributeTaskNoByReg").val(taskNo);
		$("#distributeDateByReg").val(curDate);
		$("#branchNoByReg").val(branchNo);
		$("#empNoByReg").val(userNo);
		var content="";
		$("#ditributeDetailByReg").html();
		for(var i=0;i<list.length;i++){
			var citizenCardNo = list[i].citizenCardNo;
			var cardName = list[i].cardName;
			var validStatus = list[i].validStatus;
			var companyName = list[i].companyName;
			var rejectCause = list[i].rejectCause;
			var cardCode = list[i].cardCode;
			var companyNo = list[i].companyNo;
			var rejectCauseCode = list[i].rejectCauseCode;
			var cardControlId = list[i].cardControlId;
			content+="<tr align='center'>"
			     +"<td width='2%'>"+[i+1]+"</td>"
			     +"<td width='4%'><input name='citizenCardNoByDis' style='border:0;' readonly='readonly' value='"+citizenCardNo+"'></td>"
			     +"<td width='3%'><input name='cardNameByDis' style='border:0;' readonly='readonly' value='"+cardName+"'></td>"
			     +"<td width='3%'><input name='validStatusByDis' style='border:0;' readonly='readonly' value='"+validStatus+"'></td>"
			     +"<td width='3%'><input name='companyNameByDis' style='border:0;' readonly='readonly' value='"+companyName+"'></td>"
			     +"<td width='3%'><input name='rejectCauseByDis' style='border:0;' readonly='readonly' value='"+rejectCause+"'></td>" 
			     +"<td width='3%' style='display:none;'><input name='cardCodeByDis' style='border:0;' readonly='readonly' value='"+cardCode+"'></td>"
			     +"<td width='3%' style='display:none;'><input name='companyNoByDis' style='border:0;' readonly='readonly' value='"+companyNo+"'></td>"
			     +"<td width='3%' style='display:none;'><input name='rejectCauseCodeByDis' style='border:0;' readonly='readonly' value='"+rejectCauseCode+"'></td>"
			     +"<td width='3%' style='display:none;'><input name='cardControlIdByDis' style='border:0;' readonly='readonly' value='"+cardControlId+"'></td>"
			     +"</tr>" 
		}
		$("#ditributeDetailByReg").html(content);
	}
	
}

/**
 * 子模块：网点废卡配送并出库
 * 功能：加载配送任务号到页面并请求加载配送信息
 * @param json
 */
function setTaskNo(json){
	var taskNo = json.taskNo;
	console.log("taskNo==>"+taskNo);
	$("input[name='ditributeTaskNo']").val(taskNo);
	var fileName = $("input[name='branchNo']").val()+$("input[name='ditributeTaskNo']").val()+".txt";
	console.log("任务号==>"+$("input[name='ditributeTaskNo']").val());
	console.log("文件名称为==>"+fileName);
	$.get("inventorymanagement/loadDistributeInfo",{fileName:fileName},loadDistributeInfo,"json");
}

/**
 * 子模块：网点废卡配送并出库
 * 功能：页面加载配送任务清单明细（临时）
 * @param json
 */
function loadDistributeInfo(json){
	var list = json.distributeDetailList;
	if(list){
		//alert("返回的list的长度是==>"+list.length);
		$("#cardAmount").val(list.length);
		var content="";
		$("#ditributeDetail").html();
		for(var i=0;i<list.length;i++){
			var citizenCardNo = list[i].citizenCardNo;
			var cardName = list[i].cardName;
			var validStatus = list[i].validStatus;
			var companyName = list[i].companyName;
			var rejectCause = list[i].rejectCause;
			var cardCode = list[i].cardCode;
			var companyNo = list[i].companyNo;
			var rejectCauseCode = list[i].rejectCauseCode;
			var cardControlId = list[i].cardControlId;
		//	alert("卡控制号==>"+cardControlId);
			var value = citizenCardNo+"#"+cardName+"#"+validStatus+"#"+companyName+"#"+rejectCause+"#"+cardCode+"#"+companyNo+"#"+rejectCauseCode+"#"+cardControlId;
			content+="<tr align='center'>"
				 +"<td><input name='distributeItem' onclick='test(this)' value="+value+" type='checkbox'></td>"
			     +"<td>"+[i+1]+"</td>"
			     +"<td>"+citizenCardNo+"</td>"
			     +"<td>"+cardName+"</td>"
			     +"<td>"+validStatus+"</td>"
			     +"<td>"+companyName+"</td>"
			     +"<td>"+rejectCause+"</td>" 
			     +"<td  style='display:none;'>"+cardCode+"</td>"
			     +"<td  style='display:none;'>"+companyNo+"</td>"
			     +"<td  style='display:none;'>"+rejectCauseCode+"</td>"
			     +"<td  style='display:none;'><input name='cardControlIdByDis' style='border:0;' readonly='readonly' value='"+cardControlId+"'></td>"
			     +"</tr>" 
		}
		$("#ditributeDetail").html(content);
		var $p = $("#distributetask");
		initUI($p)
	}
	
}

function parseTaskParams(json){
	var taskNo = json.taskNo;
	var branchNo = json.branchNo;
	var empNo = json.empNo;
	var controlIdList = json.controlIdLIst;
	console.log("废卡上缴==>"+branchNo+"#"+taskNo);
	console.log("controlIdList==>"+controlIdList);
	$("input[name='branchNoByCreateDis']").val(branchNo);
	$("input[name='empNoByCreateDis']").val(empNo);
	$("input[name='taskNoByCreateDis']").val(taskNo);
	$("input[name='branchNo']").val(branchNo);
	$("input[name='empNo']").val(empNo);
	$("input[name='cardControlIdList']").val(controlIdList);
}

function deleteDistributeItem(json){
	var param = json.param;
	console.log("param==>"+param);
}

/**
 * 获取废卡配送详细，加载到查询页面
 * @param json
 */
function getDistributeInfo(json){
	var content="";
	$("#rejectDitributionDetail").html();
	var item = json.distributePage;
		var numPerPage=item.numPerPage;
		//alert("page==>"+numPerPage);
		var cuurentPage=item.currentPage;
		var totalCount=item.totalCount;
		var pageCount=item.pageCount
		var list=item.list;
		//alert("length====>"+list.length);
		if(list.length==0){
			content+="<tr><td colspan='8' align='center' >未查询到数据</td></tr>"
		}else{
			for(var i=0;i<list.length;i++){
				var value=list[i].sourceBranchNo+"#"+list[i].distributeTaskNo+"#"+list[i].amount+"#"+list[i].detailInfo;
				//alert("checkBox-value==>"+value);
				content+="<tr align='center'>"
					     +"<td><input name='distributeByQuery' value="+value+" type='radio'></td>"
					     +"<td>"+[i+1]+"</td>"
					     +"<td>"+list[i].distributeTaskNo+"</td>"
					     +"<td>"+list[i].sourceBranchNo+"</td>"
					     +"<td>"+list[i].amount+"</td>"
					     +"</tr>" 
					     //inventorymanagement/getResponseFileDetail
					     //
			}
			
		}
		$("#rejectDitributionDetail").html(content);
		$("input[name='numPerPage']").val(numPerPage);
		$("input[name='currentPage']").val(cuurentPage); 
		$("input[name='pageCount']").val(pageCount);
		$("#totalCountByDis").text("条，共"+totalCount+"条");
		var pagination="<a href='#' onclick='previous()' id='previous' >上一页  </a><a href='#' onclick='next()' id='next'> 下一页</a><span>当前第"+cuurentPage+"页，共"+pageCount+"页</span>";
		$("#paginationByDis").html(pagination);
	//	initUI($("#responseFileDetail"));	
		var $p = $("#treatedis");
		initUI($p);
}

function getDistributionRejectInfo(json){
	var storageNo = json.storageNo;
	var distributeNo = json.distributeNo;
	var sourceBranchNo = json.sourceBranchNo;
	var distributeAmount = json.distributeAmount;
	$("input[name='storageNoByReceive']").val(storageNo);
	$("input[name='distributeTaskNoByReceive']").val(distributeNo);
	$("input[name='sourceBranchNoByReceive']").val(sourceBranchNo);
	$("input[name='amountByReceive']").val(distributeAmount);
	var list = json.detailList;
	var content="";
	$("#rejectDitributionDetail").html();
	if(list.length>0){
		for(var i=0;i<list.length;i++){
			var citizenCardNo = list[i].citizenCardNo;
			var cardName = list[i].cardName;
			var validStatus = list[i].validStatus;
			var companyName = list[i].companyName;
			var rejectCause = list[i].rejectCause;
			var cardCode = list[i].cardCode;
			var companyNo = list[i].companyCode;
			var rejectCauseCode = list[i].rejectCauseCode;
			var cardControlID = list[i].cardControlID;
			content+="<tr align='center'>"
			     +"<td width='2%'>"+[i+1]+"</td>"
			     +"<td width='5%'><input name='citizenCardNoByInco' style='border:0;' readonly='readonly' value='"+citizenCardNo+"'></td>"
			     +"<td width='4%'><input name='cardNameByInco' style='border:0;' readonly='readonly' value='"+cardName+"'></td>"
			     +"<td width='4%'><input name='companyNameByInco' style='border:0;' readonly='readonly' value='"+companyName+"'></td>"
			     +"<td width='4%'><input name='rejectCauseByInco' style='border:0;' readonly='readonly' value='"+rejectCause+"'></td>" 
			     +"<td width='3%' style='visibility:hidden;'><input name='cardCodeByInco' style='border:0;' readonly='readonly' value='"+cardCode+"'></td>"
			     +"<td width='3%' style='visibility:hidden;'><input name='companyNoByInco' style='border:0;' readonly='readonly' value='"+companyNo+"'></td>"
			     +"<td width='3%' style='visibility:hidden;'><input name='rejectCauseCodeByInco' style='border:0;' readonly='readonly' value='"+rejectCauseCode+"'></td>"
			     +"<td width='3%' style='visibility:hidden;'><input name='cardControlIdByInco' style='border:0;' readonly='readonly' value='"+cardControlID+"'></td>"
			     +"</tr>" 
			
		}
	}
	$("#rejectDitributionDetail").html(content);

}




//++++++++++++++++++++++++++++++++出库++++++++++++++++++++++++++++++++++++++++++++++
function getpurCardDeliery(json){
	var content="";
	/*$("#producttasked").html();*/
	var item = json.ssv;
		var numPerPage=item.numPerPage;
		//alert("page==>"+item);
		var cuurentPage=item.currentPage;
		var totalCount=item.totalCount;
		var pageCount=item.pageCount
		var list=item.list;
		//alert("length====>"+list.length);
		if(list.length==0){
			content+="<tr><td colspan='8' align='center' >未查询到数据</td></tr>"
		}else{
			for(var i=0;i<list.length;i++){
				var value=list[i].taskNo+","+list[i].cardpCode+","+list[i].branchNo;
				//alert("checkBox-value==>"+value);
				content+="<tr align='center'>"
					     +"<td width='2%'><input name='purCardDelierytasked' onclick='test(this)' value="+value+" type='checkbox'></td>"
					     +"<td width='2%'>"+[i+1]+"</td>"
					     +"<td width='2%'>"+list[i].cardpName+"</td>"
					     +"<td width='2%'>"+list[i].branchNo+"</td>"
					     +"<td width='6%'>"+list[i].taskNo+"</td>"
					     +"<td width='3%'>"+list[i].lstInDate+"</td>"
					     +"<td width='2%'>"+list[i].currNum+"</td>"
					     +"<td width='2%'>"+list[i].currNum+"</td>"
					     +"</tr>" 
					    
			}
			
		}
		$("#purCardDeliery").html(content);
		$("input[name='numPerPage']").val(numPerPage);
		$("input[name='currentPage']").val(cuurentPage); 
		$("input[name='pageCount']").val(pageCount);
		$("#totalCountBypurCardDeliery").text("条，共"+totalCount+"条");
		var pagination="<a href='#' onclick='previous()' id='previous' >上一页  </a><a href='#' onclick='next()' id='next'> 下一页</a><span>当前第"+cuurentPage+"页，共"+pageCount+"页</span>";
		$("#paginationBypurCardDeliery").html(pagination);
		//initUI($("#responseFileDetail"));
};
//加载出库详细信息
function getCardDeliveryReg(json){
	var content="";
	var item = json.ssv;
	var branchNo = item.branchNo;
	var taskNo = item.taskNo;
	var currNum = item.currNum;
	var stockSumId = item.stockSumId;
	var inStockStat = item.inStockStat;
	//卡产品名称
	var cardpName = item.cardpName;
	
	//alert("列表长度==>"+detailList.length);
	$("input[name='cardpName']").val(cardpName);
	$("input[name='branchNo']").val(branchNo);
	$("input[name='taskNo']").val(taskNo);
	$("input[name='amount']").val(currNum);
	$("input[name='stockSumId']").val(stockSumId);
	$("input[name='inStockStat']").val(inStockStat);
	
}
//+++++++++++++++++++++++++++++++++出库撤销+++++++++++++++++++++++++++++++++++++++++++++
function getOutgoRevoction(json){
	var content="";
	var item = json.sRV;
		var numPerPage=item.numPerPage;
		console.log("numPerPage==>"+numPerPage);
		var currentPage=item.currentPage;
		var onePageCount = [numPerPage*[currentPage-1]];
		var totalCount=item.totalCount;
		var pageCount=item.pageCount;
		console.log("currentPage==>"+currentPage);
		console.log("totalCount==>"+totalCount);
		var list=item.list;
	//	var flag=[0,0,0,0,0,0,0,0,0,0,0,"正常出库","盘亏出库","配送出库","退货出库","报废出库"];
		//alert("length====>"+list.length);
		if(list.length==0){
			content+="<tr><td colspan='8' align='center' >未查询到数据</td></tr>"
		}else{
			for(var i=0;i<list.length;i++){
				var value=list[i].storageRegNo+"#"+list[i].storageMode+"#"+list[i].oprBranchNo+"#"+list[i].operatorNo+"#"
				         +list[i].storageDate+"#"+list[i].storageAmount;
				//alert("checkBox-value==>"+value);
				content+="<tr align='center'>"
					     +"<td><input name='outgoRecotiontasked' onclick='test(this)' value="+value+" type='radio'></td>"
					     +"<td>"+eval(i+1+parseInt(onePageCount))+"</td>"
					     +"<td>"+list[i].storageRegNo+"</td>"
					     +"<td>"+list[i].oprBranchNo+"</td>"
					     +"<td>"+list[i].operatorNo+"</td>"
					     +"<td>"+list[i].storageModeDesc+"</td>"
					     +"<td>"+list[i].storageDate+"</td>"
					     +"<td>"+list[i].storageAmount+"</td>"
					     +"</tr>" 
					    
			}
			
		}
		$("#outgoingRecotion").html(content);
		$("input[name='numPerPage']").val(numPerPage);
		$("input[name='pageNum']").val(currentPage); 
//		$("input[name='pageCount']").val(pageCount);
		$("#totalCountByoutgoRecotion").text("条，共"+totalCount+"条");
		
		$("#paginationByoutgoRecotion").addClass("pagination").attr("targetType","navTab").attr("totalCount",totalCount).attr("numPerPage",numPerPage).attr("pageNumShown","10").attr("currentPage",currentPage).attr("rel","outgoingRecotion").attr("callback","getOutgoRevoction");
		$("div.pagination").each(function(){
			var $this = $(this);
			$this.pagination({
				targetType:"navTab",
				rel:"outgoingRecotion",
				totalCount:totalCount,
				numPerPage:numPerPage,
				pageNumShown:10,
				currentPage:currentPage,
				callback:getOutgoRevoction
			});
		});
		var $p = $("#outgorevocation");
		initUI($p);
		
};
//加载出库详细信息
function OutgoRevoctionReg(json){
	var content="";
	var item = json.srv;
	var storageNo = item.storageNo;
	var storageMode = item.storageMode;
	var amount = item.amount;
	var storageDate = item.storageDate;
	var remark = item.remark;
	var lstOutOperator = item.lstOutOperator;
	var stockSumId = item.stockSumId;
	//卡产品名称
	var cardpName = item.cardpName;
	var taskNo = item.taskNo;
	var flag=[0,0,0,0,0,0,0,0,0,0,0,"正常出库","盘亏出库","配送出库","退货出库","报废出库"];
	content+="<option value='"+storageMode+"'>"+flag[storageMode]+"</option>"
	//alert("列表长度==>"+detailList.length);
	$("input[name='cardpName']").val(cardpName);
	$("input[name='storageNo']").val(storageNo);
	$("#storageModeBYOR").html(content);
	$("input[name='amount']").val(amount);
	$("input[name='storageDate']").val(storageDate);
	$("input[name='lstOutOperator']").val(lstOutOperator);
	$("input[name='remark']").val(remark);
	$("input[name='stockSumId']").val(stockSumId);
	$("input[name='taskNo']").val(taskNo);
}
//+++++++++++++++++++++++++++++++++网点接收配送+++++++++++++++++++++++++++++++++++++++++++++
function getCardReceiving(json){
	var content="";
	var item = json.srrv;
		var numPerPage=item.numPerPage;
		//alert("page==>"+item.list[0].storageNo);
		var currentPage=item.currentPage;
		var totalCount=item.totalCount;
		//alert(totalCount);
		if(item.totalCount==0){
			totalCount = 0;
		}
		var pageCount=item.pageCount;
		var list=item.list;
		
		//alert("length====>"+list.length);
		if(list.length==0){
			content+="<tr><td colspan='8' align='center' >未查询到数据</td></tr>"
		}else{
			for(var i=0;i<list.length;i++){
				var value=list[i].taskNo+"#"+list[i].cardPCode+"#"+list[i].cardPName+"#"+list[i].desBranchNo+"#"
				          +list[i].amount+"#"+list[i].storageNo+"#"+list[i].applyBatchNo+"#"+list[i].distributeTaskNo+"#"+list[i].taskName;
				//alert("checkBox-value==>"+value);
				content+="<tr align='center'>"
					     +"<td><input name='cardReceivingtasked' onclick='test(this)' value="+value+" type='checkbox'></td>"
					     +"<td>"+[i+1]+"</td>"
					     +"<td>"+list[i].applyBatchNo+"</td>"
					     +"<td>"+"<a class='linkStyle' href='#' onclick='openDialogTaskeds(this)' >"+list[i].taskNo+"</a></td>"
					     +"<td>"+list[i].distributeTaskNo+"</td>"
					     +"<td>"+list[i].cardPName+"</td>"
					     +"<td>"+list[i].desBranchNo+"</td>"
					     +"<td>"+list[i].desBranchName+"</td>"
					     +"<td>"+list[i].recordNum+"</td>"
					     +"<td>"+list[i].amount+"</td>"
					     +"<td>"+list[i].storageDate+"</td>"
				//	     +"<td style='display:none;'><input style='border:0;text-align:center;' name='cardPhysicTypeByReceiving' value='"+list[i].taskName+"' size='15'></td>"
					     +"</tr>" 	    
			}
			
		}
		$("#cardReceiving").html(content);
		$("input[name='numPerPage']").val(numPerPage);
		$("input[name='pageNum']").val(currentPage); 
		$("input[name='pageCount']").val(pageCount);
		$("#totalCountByCardReceivingn").text("条，共"+totalCount+"条");
		$("#paginationByCardReceiving").addClass("pagination").attr("targetType","navTab").attr("totalCount",totalCount).attr("numPerPage",numPerPage).attr("pageNumShown","10").attr("currentPage",currentPage).attr("rel","cardReceiving").attr("callback","getCardReceiving");
		$("div.pagination").each(function(){
			var $this = $(this);
			$this.pagination({
				targetType:"navTab",
				rel:"cardReceiving",
				totalCount:totalCount,
				numPerPage:numPerPage,
				pageNumShown:10,
				currentPage:currentPage,
				callback:getCardReceiving
			});
		});
		
		var $p = $("#cardRec");
		initUI($p);
};
//加载网点接收配送详细信息 

function getcardReceivingInfo(json){
	var content="";
	$("#cardReceivingByDetail").html("");
	var item = json.srrv;
	var paperNoCode = ["身份证","户口溥","护照","港澳居民来往内地通行证","台湾同胞来往内地通行证","外国人永久居留证","军官证","士兵证","残疾人证","其他"];
	//var storageNo = item.storageNo;
	if(item.length>0){
		var taskNo = item[0].taskNo;
		var cardPName = item[0].cardPName;
		var applyDate = item[0].tasksGeneTime;

		$("input[name='taskNoByDetail']").val(taskNo);
		$("input[name='cardpNameByDetail']").val(cardPName);
		//$("#storageModeBYOR").html(content);
		$("input[name='applyDate']").val(applyDate);
		
		for(var i=0;i<item.length;i++){
			var claimStatus = item[i].claimStatus;
			var returnFlag = "";
			var paperType = item[i].paperType;
			var mode = paperNoCode[parseInt(paperType)];
			if(parseInt(claimStatus)==7){
				returnFlag = "配送返回";
			}
			//这里需要明确各个状态的含义吗？
			if(parseInt(claimStatus)<7){
				returnFlag = "未返回";
			}
			content+= "<tr align='center'>"+
					    "<td>"+[i+1]+"</td>" +
					    "<td>"+item[i].customerName+"</td>"+
					    "<td>"+item[i].paperType+"</td>" +
					    "<td>"+item[i].paperNo+"</td>" +
					    "<td>"+item[i].citizenCardNo+"</td>" +
					    "<td>"+returnFlag+"</td>" +
					  "</tr>" 
		}
		$("#cardReceivingByDetail").html(content);
		//$("#paginationByCardReceiving").html(pagination);
		var $p = $("#cardReceivingReg");
		initUI($p);
	}
}
//-------获取入库撤销的信息--------------------------------------------------------------------------------	
//获取入库撤销信息回调函数
function getStorageCancel(json){
	var content="";
		var item = json.srv;
		var numPerPage=item.numPerPage;
		var currentPage=item.currentPage;
		var onePageCount = [numPerPage*[currentPage-1]];
		console.log("onePageCount==>"+onePageCount);
		var totalCount=item.totalCount;
		var pageCount=item.pageCount
		var list=item.list;
		var flag = ["否","是"];
	//	var storageModeCode = ["正常入库","盘盈入库","接收入库","回收入库"];
		if(list.length==0){
			content+="<tr><td colspan='8' align='center' >未查询到数据</td></tr>"
		}else{
			for(var i=0;i<list.length;i++){
				var storageMode = list[i].storageMode;
			//	var mode = storageModeCode[parseInt(storageMode)-1];
				var mode = list[i].storageModeDesc;
				console.log("mode===>"+mode);
				console.log("page===>"+eval(i+1+parseInt(onePageCount)));
				var value=list[i].storageRegNo+"#"+list[i].storageMode+"#"+list[i].oprBranchNo+"#"+
				          list[i].operatorNo+"#"+list[i].storageDate+"#"+list[i].storageAmount;
				content+="<tr align='center'><td width='2%'><input name='StorageCanceled' onclick='test(this)' value="+value+" type='radio'></td>" +
				"<td>"+eval(i+1+parseInt(onePageCount))+"</td>"+
				"<td>"+list[i].storageRegNo+"</td>" +
				"<td>"+list[i].oprBranchNo+"</td>" +
				"<td>"+list[i].operatorNo+"</td>" +
				"<td>"+mode+"</td>" +
				"<td>"+list[i].storageDate+"</td>" +
			    "<td>"+list[i].storageAmount+"</td></tr>" 
			}
			
		}
		$("#StorageCance").html(content);
		$("input[name='numPerPage']").val(numPerPage);
		$("input[name='pageNum']").val(currentPage); 
		$("input[name='pageCount']").val(pageCount);
		$("#totalCountByStorCan").text("条，共"+totalCount+"条");
		$("#paginationByStorageCancel").addClass("pagination").attr("targetType","navTab").attr("totalCount",totalCount).attr("numPerPage",numPerPage).attr("pageNumShown","10").attr("currentPage",currentPage).attr("rel","StorageCance").attr("callback","getStorageCancel");
		$("div.pagination").each(function(){
			var $this = $(this);
			$this.pagination({
				targetType:"navTab",
				rel:"StorageCance",
				totalCount:totalCount,
				numPerPage:numPerPage,
				pageNumShown:10,
				currentPage:currentPage,
				callback:getStorageCancel
			});
		});
		var $p = $("#storagecancel");
		initUI($p);

};
//-------获取修改的信息--------------------------------------------------------------------------------
function getStorageCanceRe(json){
	var content="";
	$(json).each(function(n,item){
			$("#storageNoBysC").val(item.sr.storageNo);
			$("#storageModeBySC").val(item.sr.storageMode);
			/*$("#cardpNameBySC").val(item.sr.cardpName);*/
			$("#storageDateBySC").val(getDate(item.sr.storageDate));
			$("#amountBySC").val(item.sr.amount);
		//	$("#lstInOperatorBySC").val(item.sd.lstInOperator);
			$("#remarkBySC").val(item.sr.remark);
			$("#businessNoBySC").val(item.sr.businessNo);
			
				/*content+="<tr align='center'>"
				     +"<td width='2%'>"+[1]+"</td>"
				     +"<td width='4%'>"+item.sd.itemAttrVal01+"</td>"
				     +"<td width='4%'>"+item.sd.itemAttrVal02+"</td>"
				     +"<td width='5%'>"+item.sd.itemAttrVal03+"</td>"
				     +"<td width='5%'>"+item.sd.itemAttrVal04+"</td>"
				     +"<td width='3%'>"+item.sd.itemAttrVal05+"</td>"
				     +"<td width='3%'>"+item.sd.amount+"</td>"
				     +"</tr>" */
			
			$("#StorageCanceRes").html(content);	
		})
	
}

//-------卡片上交--------------------------------------------------------------------------------	
//获取卡片信息回调函数
function getCardHand(json){
	$(json).each(function(n,item){
		var list=item.list;
		var content="";
		var citizenNoArray = "";
	 console.log("list==>"+list);
		if(list.length==0){
			content+="<tr><td colspan='8' align='center' >请读取卡片！</td></tr>"
		}else{
			var list=item.list;
			var content="";
			
				for(var i=0;i<list.length;i++){
					var cardpCode = list[i].cardpCode;
					var citizenCardNo = list[i].citizenCardNo;
					var value=citizenCardNo+"#"+cardpCode;
					if(i==0){
						citizenNoArray = citizenCardNo;
					}else{
						citizenNoArray = citizenNoArray + "#" + citizenCardNo;
					}
					citizenNoArray = citizenCardNo ;
					content+="<tr align='center'>"
					     +"<td><input name='handtasked' onclick='test(this)' value="+value+" type='checkbox'></td>"
					     +"<td>"+[i+1]+"</td>"
					     +"<td>"+citizenCardNo+"</td>"
					     +"<td>"+cardpCode+"</td>"
					     +"</tr>"
				
			}
		}
		$("input[name='newCitizenCardNo']").val(citizenNoArray);
		$("#cardhand").html(content);
		var $p = $("#cardHanding");
		initUI($p);
		initUI($(".panelBar"));
		
	})
};

//中心库接收空白卡/成品卡上缴
function getBlankAndFinishCardReceiving(json){
	var content="";
	var distributeNo = json.distributeNo;
	var item = json.list;
		
		var numPerPage=item.numPerPage;
		//alert("page==>"+item.list[0].storageNo);
		var currentPage=item.currentPage;
		var totalCount=item.totalCount;
		//console.log("total==>"+total);
		var pageCount=item.pageCount;
		var list=item.list;
		
		//alert("length====>"+list.length);
		if(list.length==0){
			content+="<tr><td colspan='8' align='center' >未查询到数据</td></tr>"
		}else{
			for(var i=1;i<list.length;i++){
				var value=distributeNo+"#"+list[i].citizenCardNo+"#"+list[i].cardpCode+"#"
				+list[i].cardType+"#"+list[i].stockType;
				//console.log("value===>"+value);
				//alert("checkBox-value==>"+value);
				content+="<tr align='center'>"
					     +"<td><input name='blankCardReceivingtasked' onclick='test(this)' value="+value+" type='checkbox'></td>"
					     +"<td>"+[i]+"</td>"
					     +"<td>"+list[i].citizenCardNo+"</td>"
					     +"</tr>" 	    
			}
			
		}
		$("#blankAndFinishCardReceiving").html(content);
		$("input[name='numPerPage']").val(numPerPage);
		$("input[name='currentPage']").val(currentPage); 
		$("input[name='pageCount']").val(pageCount);
		$("#totalCountByBlankAndFinished").text("条，共"+totalCount+"条");
		$("#paginationByQueryBlankAndFinishCard").addClass("pagination").attr("targetType","navTab").attr("totalCount",totalCount).attr("numPerPage",numPerPage).attr("pageNumShown","10").attr("currentPage",currentPage).attr("rel","blankAndFinishCardReceiving").attr("callback","getBlankAndFinishCardReceiving");
		$("div.pagination").each(function(){
			var $this = $(this);
			$this.pagination({
				targetType:"navTab",
				rel:"blankAndFinishCardReceiving",
				totalCount:totalCount,
				numPerPage:numPerPage,
				pageNumShown:10,
				currentPage:currentPage,
				callback:getBlankAndFinishCardReceiving
			});
		});
		
	//	$("#paginationByCardReceiving").html(pagination);
		var $p = $("#blankandfinshcardrec");
		initUI($p);
};


//中心库接收废卡上缴
function getRejectCardReceiving(json){
	var content="";
	var distributeNo = json.distributeNo;
	var item = json.list;
		var numPerPage=item.numPerPage;
		//alert("page==>"+item.list[0].storageNo);
		var currentPage=item.currentPage;
		var totalCount=item.totalCount;
		var pageCount=item.pageCount;
		var list=item.list;
		
		//alert("length====>"+list.length);
		if(list.length==0){
			content+="<tr><td colspan='8' align='center' >未查询到数据</td></tr>"
		}else{
			for(var i=0;i<list.length;i++){
				var value=distributeNo+"#"+list[i].citizenCardNo+"#"+list[i].cardpCode
				             +"#"+list[i].cardType+"#"+list[i].stockType;
				//alert("checkBox-value==>"+value);
				content+="<tr align='center'>"
					     +"<td><input name='blankCardReceivingtasked' onclick='test(this)' value="+value+" type='checkbox'></td>"
					     +"<td>"+[i+1]+"</td>"
					     +"<td>"+list[i].citizenCardNo+"</td>"
					     +"</tr>" 	    
			}
			
		}
		$("#rejectCardReceiving").html(content);
		$("input[name='numPerPage']").val(numPerPage);
		$("input[name='pageNum']").val(currentPage); 
		$("input[name='pageCount']").val(pageCount);
		$("#totalCountByRejectCardReceivingn").text("条，共"+totalCount+"条");
		
		$("#paginationByRejectCardReceiving").addClass("pagination").attr("targetType","navTab").attr("totalCount",totalCount).attr("numPerPage",numPerPage).attr("pageNumShown","10").attr("currentPage",currentPage).attr("rel","rejectCardReceiving").attr("callback","getRejectCardReceiving");
		$("div.pagination").each(function(){
			var $this = $(this);
			$this.pagination({
				targetType:"navTab",
				rel:"rejectCardReceiving",
				totalCount:totalCount,
				numPerPage:numPerPage,
				pageNumShown:10,
				currentPage:currentPage,
				callback:getRejectCardReceiving
			});
		});
		var $p = $("#rejectcard");
		initUI($p);
};


//出入库表单打印
function getStorageList(json){
	var content="";
	var list = json.list;
	var ipAddress = json.ipAddress;
	//alert("page==>"+item.list);
	//	var numPerPage=item.numPerPage;
		
	//	var currentPage=item.currentPage;
	//	var totalCount=item.totalCount;
	//	var pageCount=item.pageCount;
	//	var onePageCount = [numPerPage*[currentPage-1]];
	//	var storageModeCode = ["制卡入库","接收制卡配送","废卡回收","白卡回收","盘盈入库","制卡配送","未知","白卡上缴","盘亏出库","废卡上缴"];
		//alert("length====>"+list.length);
		if(list.length==0){
			content+="<tr><td colspan='8' align='center' >未查询到数据</td></tr>"
		}else{
			for(var i=0;i<list.length;i++){
				var storageNo = list[i].storageNo;
				var storageMode = list[i].storageMode;
				var storageModeDesc = list[i].storageModeDesc;
				var storageDate = list[i].storageDate;
				var storageBranchNo = list[i].operateBranchNo;
				var storageBranchName = list[i].operateBranchName;
				var storageDesBranchNo = list[i].desBranchNo;
				var storageEmpNo = list[i].operatorNo;
				var storageEmpName = list[i].operatorName;
				//alert("checkBox-value==>"+value);
				content+="<tr align='center'>"
					     +"<td>"+eval(i+1/*+parseInt(onePageCount)*/)+"</td>"
					     +"<td>"+"<a class='linkStyle' href='inventorymanagement/getStorageFile' target='dialog' rel='出入库清单' credentialNo='"+storageNo+
					     	"' credential_type='storage' ipAddress='"+ipAddress+"' max='true'>"+storageNo+"</a></td>"
					     +"<td>"+storageModeDesc+"</td>"
					     +"<td>"+storageDate+"</td>"
					     +"<td>"+storageBranchNo+"</td>"
					     +"<td>"+storageBranchName+"</td>"
					     +"<td>"+storageEmpNo+"</td>"
					     +"<td>"+storageEmpName+"</td>"
					     +"</tr>" 	    
			}	
		}
		$("#storageList").html(content);
	//	$("input[name='numPerPage']").val(numPerPage);
	//	$("input[name='pageNum']").val(currentPage); 
		//$("input[name='pageCount']").val(pageCount);
	//	$("#totalCountByStorageList").text("条，共"+totalCount+"条");
		//var pagination="<a href='#' onclick='previous()' id='previous' >上一页  </a><a href='#' onclick='next()' id='next'> 下一页</a><span>当前第"+cuurentPage+"页，共"+pageCount+"页</span>";
		//$("#paginationByStorageList").html(pagination);
	//	$("#paginationByStorageList").addClass("pagination").attr("targetType","navTab").attr("totalCount",totalCount).attr("numPerPage",numPerPage).attr("pageNumShown","10").attr("currentPage",currentPage).attr("rel","storageList").attr("callback","getStorageList");
		/*$("div.pagination").each(function(){
			var $this = $(this);
			$this.pagination({
				targetType:"navTab",
				rel:"storageList",
				totalCount:totalCount,
				numPerPage:numPerPage,
				pageNumShown:10,
				currentPage:currentPage,
				callback:getStorageList
			});
		});*/
		initUI($("#storageList"));
		var $p = $("#storagelists");
		initUI($p);
};


function queryCardByBlankAppAndBatchAppInfo(json){
	console.log("123456");
	var content="";
	var item = json.list;
		var numPerPage=item.numPerPage;
		//alert("page==>"+item.list[0].storageNo);
		var cuurentPage=item.currentPage;
		var totalCount=item.totalCount;
		var pageCount=item.pageCount;
		var list=item.list;
		
		//alert("length====>"+list.length);
		if(list.length==0){
			content+="<tr><td colspan='8' align='center' >未查询到数据</td></tr>"
		}else{
			for(var i=0;i<list.length;i++){
				var cardTaskNo = list[i].cardTaskNo;
				var corpCode = list[i].corpCode;
				var corpName = list[i].corpName;
				var CardDataList = list[i].cardDataList;
				console.log("cardTaskNo==>"+cardTaskNo);
				console.log("corpCode==>"+corpCode);
				console.log("corpName==>"+corpName);
				for(var j=0;j<CardDataList.length;j++){
					var citizenCardNo = CardDataList[j].citizenCardNo;
					var cardDataId = CardDataList[j].cardDataId;
					var value = citizenCardNo+"#"+cardDataId;
					console.log("卡号是===>"+citizenCardNo);
					content+="<tr align='center'>"
						 +"<td><input name='receiveCardInfotasked' onclick='test(this)' value="+value+" type='checkbox'></td>"
					     +"<td>"+[(i+1)*j+1]+"</td>"
					     +"<td>"+citizenCardNo+"</td>"
					     +"<td>"+cardTaskNo+"</td>"
					     +"<td>"+corpName+"</td>"
					     +"</tr>" 	
				}    
			}	
		}
		$("#blankAppAndBatchAppCardInfo").html(content);
		$("input[name='numPerPage']").val(numPerPage);
		$("input[name='currentPage']").val(cuurentPage); 
		$("input[name='pageCount']").val(pageCount);
		$("#totalCountByEmpReceiving").text("条，共"+totalCount+"条");
		var pagination="<a href='#' onclick='previous()' id='previous' >上一页  </a><a href='#' onclick='next()' id='next'> 下一页</a><span>当前第"+cuurentPage+"页，共"+pageCount+"页</span>";
		$("#paginationByEmpReceiving").html(pagination);
		var $p = $("#empreceive");
		initUI($p);

}


//加载网点柜员领用信息
function queryBatchApplyRecords(json){
	var content="";
	var list = json.applyBatchInfo;
	var branchNo = json.branchNo;
	var empNo = json.empNo;
	if(branchNo){
		$("#branchNoByEmpReceived").val(branchNo);
	}
	if(empNo){
		$("#empNoByReceived").val(empNo);
	}
//	var item = json.list;
//		var numPerPage=item.numPerPage;
		//alert("page==>"+item.list[0].storageNo);
//		var currentPage=item.currentPage;
//		var totalCount=item.totalCount;
//		var pageCount=item.pageCount;
//		var list=item.list;
		
		//alert("length====>"+list.length);
		if(list.length==0){
			content+="<tr><td colspan='8' align='center' >未查询到数据</td></tr>"
		}else{
			for(var i=0;i<list.length;i++){
				var value=list[i].taskNo+"#"+list[i].amount+"#"+list[i].cardPName+"#"+list[i].cardPCode+"#"+list[i].taskName;
			//	console.log("value===>"+value);
				var dateString = getDate(list[i].applyDate);
				//alert("checkBox-value==>"+value);
				content+="<tr align='center'>"
					     +"<td><input name='empReceivedInfoChecked' onclick='test(this)' value="+value+" type='checkbox'></td>"
					     +"<td>"+[i+1]+"</td>"
					     +"<td>"+list[i].cardPName+"</td>"
					     +"<td>"+list[i].cardType+"</td>"
					     +"<td>"+list[i].corpName+"</td>"
					     +"<td>"+dateString+"</td>"
					     +"<td>"+list[i].amount+"</td>"
					     +"<td>"+list[i].taskNo+"</td>"
					     +"</tr>" 	    
			}
			
		}
		$("#tbodyqueryBatchApplyRecords").html(content);
//		$("input[name='numPerPage']").val(numPerPage);
//		$("input[name='pageNum']").val(currentPage); 
//		$("input[name='pageCount']").val(pageCount);
//		$("#totalCountByRejectCardReceivingn").text("条，共"+totalCount+"条");
		
//		$("#paginationByRejectCardReceiving").addClass("pagination").attr("targetType","navTab").attr("totalCount",totalCount).attr("numPerPage",numPerPage).attr("pageNumShown","10").attr("currentPage",currentPage).attr("rel","rejectCardReceiving").attr("callback","getRejectCardReceiving");
/*		$("div.pagination").each(function(){
			var $this = $(this);
			$this.pagination({
				targetType:"navTab",
				rel:"rejectCardReceiving",
				totalCount:totalCount,
				numPerPage:numPerPage,
				pageNumShown:10,
				currentPage:currentPage,
				callback:getRejectCardReceiving
			});
		});
*/		var $p = $("#ByQueryBatchApplyRecords");
		initUI($p);
}

function getBlankCardInfoByEmpReceive(json){
	var content = "";
	var list = json.blankCardInfoList;
	if(list.length==0){
		content+="<tr><td colspan='8' align='center' >没有可用库存</td></tr>"
	}else{
		for(var i=0;i<list.length;i++){
		//	var value=list[i].taskNo+"#"+list[i].amount+"#"+list[i].cardPName+"#"+list[i].cardPCode;
		//	console.log("value===>"+value);
		//	var dateString = getDate(list[i].applyDate);
			//alert("checkBox-value==>"+value);
			content+="<tr align='center'>"
				     +"<td>"+[i+1]+"</td>"
				     +"<td><input style='border:0;text-align:center;' readonly='readonly' name='receiveCardPName' value='"+list[i].cardPName+"'></td>"
				     +"<td>"+list[i].cardType+"</td>"
				     +"<td>"+list[i].amount+"</td>"
				     +"<td><input onblur='checkQuantity(this)' style='text-align:center;' size='5' name='requiredAmountByEmpReceive' id='requiredAmountByEmpReceive' value=''></td>"
				     +"<td style='display:none;'><input style='border:0;text-align:center;' name='receiveCardPCode' value='"+list[i].cardPCode+"' size='15'></td>"
				     +"</tr>" 	    
		}
		
	}
	$("#EmpReceiveBlankCard").html(content);
	var $p = $("#ByEmpReceiveBlankCard");
	initUI($p);
	
}

var contenta = "";
var contentb = "";
$.get("applicationSingle/getCardInfo",function(data){
	 contentb="<option value='99'>未知</option>";
	 contenta="<option value='99'>未知</option>";
	var i;
	$(data).each(function(n,item){
		var cardTypeCode = item.cardTypeCode;
		var cardCode = item.cardCode;		
		for(i=0;i<item.cdPhysicsTypes.length;i++){
			if(item.cdPhysicsTypes[i].cardTypeCode==cardTypeCode){
				contenta+="<option value="+item.cdPhysicsTypes[i].cardTypeCode+" selected>"
				+item.cdPhysicsTypes[i].cardTypeName+"</option>"
			}else{
				contenta+="<option value="+item.cdPhysicsTypes[i].cardTypeCode+">"
				+item.cdPhysicsTypes[i].cardTypeName+"</option>"
			}
			
		};
		for(i=0;i<item.cdProDefinitions.length;i++){
			if(item.cdProDefinitions[i].cardpCode==cardCode){
				contentb+="<option value="+item.cdProDefinitions[i].cardpCode+" selected>"
				+item.cdProDefinitions[i].cardpName+"</option>"
			}else{
				contentb+="<option value="+item.cdProDefinitions[i].cardpCode+">"
				+item.cdProDefinitions[i].cardpName+"</option>"
			}
			
		}
	});
});
var contentClassfy = "<option value=''>请选择</option>"
					+"<option value='1'>空白卡(新)</option>"
					+"<option value='2'>成品卡(新)</option>"
					+"<option value='3'>废卡</option>"

function addCardInfo(obj){
		
		var $this = $(obj);
		var originalHtml = "";
		var param = $this.attr("param");
		//先获取tbody的行数，作为区别每个ID的值，以及序号
		var trCounts = $("#tdInfoBy"+param).find("tr").length;
		//获取原有下拉框被选中的值
		$("select[name='cardCodeBy"+param+"']").each(function(index,item){
			//卡产品下拉选
			var valueSelected = $(item).val();
			var $cardCodeItem = $(item).parent().parent().parent().find("td").eq(2).find("select");
			if(valueSelected){
				$(item).find("option[value='"+valueSelected+"']").attr("selected",true);
			}

			//卡类型下拉选
			var $typeItem = $(item).parent().parent().parent().find("td").eq(3).find("select");
			var valuePhysicTypeSelected = $typeItem.val();
			
			if(valuePhysicTypeSelected){
				$typeItem.find("option[value='"+valuePhysicTypeSelected+"']").attr("selected",true);
			}

			//卡号选项
			var $citizenCardNoItem = $(item).parent().parent().parent().find("td").eq(4).find("input").eq(0);
			var citizenCardNoSelected = $citizenCardNoItem.val();
			
			if(citizenCardNoSelected){
				$citizenCardNoItem.attr("value",citizenCardNoSelected);
			}
			//库存卡类型下拉选
			var $stockTypeItem = $(item).parent().parent().parent().find("td").eq(5).find("select");
			var stockTypeSelected = $stockTypeItem.val();
			if(stockTypeSelected){
				$stockTypeItem.find("option[value='"+stockTypeSelected+"']").attr("selected",true);
			}
			//隐藏的卡片是否读取input框
			var $cardIsRead = $(item).parent().parent().parent().find("td").eq(6).find("input");
			var cardIsRead = $cardIsRead.val();
			if(cardIsRead){
				$cardIsRead.attr("value",cardIsRead);
			}
			
			originalHtml += "<tr id='table'"+(index+1)+">"
							+"<td><input name='checkedInfoBy"+param+"' onclick='test(this)' value='"+(index+1)+"' type='checkbox'></td>"
							+"<td>"+(index+1)+"</td>"
							+"<td>"+$cardCodeItem.parent().html()+"</td>"
							+"<td>"+$typeItem.parent().html()+"</td>"
							+"<td>"+$citizenCardNoItem.parent().html()+"</td>"
							+"<td>"+$stockTypeItem.parent().html()+"</td>"
							+"<td style='display:none;'>"+$cardIsRead.parent().html()+"</td>"
							+"</tr>"
		});
		/*$("select[name='cardTypeBy"+param+"']").each(function(index,item){
			
			var valueSelected = $(item).val();
			if(valueSelected){
				$(item).find("option[value='"+valueSelected+"']").attr("selected",true);
			}
		});
		$("select[name='stockTypeBy"+param+"']").each(function(index,item){
			
			var valueSelected = $(item).val();
			if(valueSelected){
				$(item).find("option[value='"+valueSelected+"']").attr("selected",true);
			}
		});
		$("input[name='cardNoBy"+param+"']").each(function(index,item){
			
			var citizenCardNo = $(item).val();
			if(citizenCardNo){
				$(item).attr("value",citizenCardNo);
			}
		});*/
		
		
		
		var id = parseInt(trCounts)+1;
		//empReceivedInfoChecked
		var addHtml = "<tr id='table'"+id+">"
						+"<td><input name='checkedInfoBy"+param+"' onclick='test(this)' value='"+id+"' type='checkbox'></td>"
						+"<td>"+id+"</td>"
						+"<td><select id='cardCodeBy"+param+ "' name='cardCodeBy"+param+ "'>"+contentb+"</select></td>"
						+"<td><select id='cardTypeBy"+param+ "'  name='cardTypeBy"+param+ "'>"+contenta+"</select></td>"
						+"<td><input name='cardNoBy"+param+"' id='cardNoBy"+param+"' size='15' class='validCitizenCardNo rememberMe' value=''>"+
						"<input type='button' value='读卡' param='"+param+"' onclick='readCardByInventory(this)'></td>"
						+"<td><select id='stockTypeBy"+param+ "'  name='stockTypeBy"+param+ "'>"+contentClassfy+"</select></td>"
						+"<td style='display:none;'><input name='cardIsReadBy"+param+"' id='cardIsReadBy"+param+"' size='15' value=''></td>"
						+"</tr>"
						
		$("#tdInfoBy"+param).html("");
		$("#tdInfoBy"+param).html(originalHtml+addHtml);
		var $task = $("#tableInfoBy"+param);
		initUI($task);
}

function readCardByInventory(obj){
	var $obj = $(obj);
	var cardPCodeAndName = "";
	var param = $obj.attr("param");
	var storageMode = $("#storageModeBy"+param).val();
	var physicTypeAndName = "";
	var $inputCitizenNo = $obj.prev();
	var $cardPCodeItem = $obj.parent().parent().parent().find("td").eq(2);
	var $cardTypeCodeItem = $obj.parent().parent().parent().find("td").eq(3);
	var $stockTypeItem = $obj.parent().parent().parent().find("td").eq(5);
	var $cardIsRead = $obj.parent().parent().parent().find("td").eq(6);
	var cardFlag = true;
	//清空信息
	$("input",$cardIsRead).attr("value","");
	$inputCitizenNo.val("");
	$("select",$cardPCodeItem).val("");
	$("select",$cardTypeCodeItem).val("");
	$("select",$stockTypeItem).val("");
	$inputCitizenNo.removeAttr("disabled");
	var flag=activeCPU();
	if(flag){
		flag=qzsmkocx.GetSmkNo();
	}
	var f;
	var text;
	if(flag){
		var citizenCardNo=qzsmkocx.GetRetValue().split(",")[0];
		
		$inputCitizenNo.val(citizenCardNo);
		$.post("inventorymanagement/queryCardInfoByCardNo",{"citizenCardNo":citizenCardNo},function(json){
			var obj = json.cardAndCustInfo;
			if(!obj){
				alertMsg.warn("查不到该卡的信息，请联系管理员！不能作出入库操作");
				$("select",$cardPCodeItem).html(contentb);
				$("select",$cardTypeCodeItem).html(contenta);	
				$inputCitizenNo.val("");
				return false;
			}
			var activeUser = json.activeUser;
			var currentBranchNo = activeUser.branchNo;
			var cardPcode = obj.cardPcode;
			var cardPName = obj.cardPName;
			var physicTypeCode = obj.physicTypeCode;
			var typeName = obj.typeName;
			var cardStatus = obj.cardStatus;
			var cardPosition = obj.cardPosition;
			console.log("cardPosition==>"+cardPosition);
			var lastBranchNo = obj.lastBranchNo;
			var stockType = "";
			//新卡或废卡
			if(cardStatus=="0"&&obj.taskType){
				stockType = obj.taskType;
			}else{
				stockType = "3";
			}
			if("13"==storageMode){
				if("0"!=cardStatus){
					alertMsg.warn("该卡不是空白或成品卡的新卡，不能作为新卡上缴出入库操作！");
					$inputCitizenNo.val("");
					cardFlag = false;
					return false;
				}
				if("2"!=cardPosition){
					alertMsg.warn("该卡位置信息有误，请联系管理员！不能作出入库操作");
					$inputCitizenNo.val("");
					cardFlag = false;
					return false;
				}else if(currentBranchNo!=lastBranchNo){
					//查询该卡的网点，与先操作员是否一致
					alertMsg.warn("该卡位置信息有误，请联系管理员！不能作出入库操作");
					$inputCitizenNo.val("");
					cardFlag = false;
					return false;
				}
			}
			if("15"==storageMode){
				if("0"==cardStatus){
					alertMsg.warn("该卡是空白或成品卡的新卡，不能作为废卡上缴出入库操作！");
					$inputCitizenNo.val("");
					cardFlag = false;
					return false;
				}
				if("2"!=cardPosition){
					alertMsg.warn("该卡位置信息有误，请联系管理员！不能作出入库操作");
					$inputCitizenNo.val("");
					cardFlag = false;
					return false;
				}else if(currentBranchNo!=lastBranchNo){
					//查询该卡的网点，与先操作员是否一致
					alertMsg.warn("该卡位置信息有误，请联系管理员！不能作出入库操作");
					$inputCitizenNo.val("");
					cardFlag = false;
					return false;
				}
			}
			if("06"==storageMode){
				if(currentBranchNo!=lastBranchNo){
					//查询该卡的网点，与先操作员是否一致
					alertMsg.warn("该卡位置信息有误，请联系管理员！不能作出入库操作");
					$inputCitizenNo.val("");
					cardFlag = false;
					return false;
				}
				if("3"!=cardPosition){
					alertMsg.warn("卡信息有误，请联系管理员！不能作出入库操作！");
					$inputCitizenNo.val("");
					cardFlag = false;
					return false;
				}
			}
			//盘盈入库，不需要验证
			//盘亏出库，无法验证
		//	cardPCodeAndName = "<option value='"+cardPcode+"'>"+cardPName+"</option>";
		//	physicTypeAndName = "<option value='"+physicTypeCode+"'>"+typeName+"</option>";
			$("select",$cardPCodeItem).val(cardPcode);
			$("select",$cardTypeCodeItem).val(physicTypeCode);
			$("select",$stockTypeItem).val(stockType);
			//将卡片读取选项置1
			
			$("input",$cardIsRead).attr("value","1");
			$inputCitizenNo.attr("readonly","readonly").attr("onfocus","this.blur();");
		//	$("select",$cardTypeCodeItem).html(physicTypeAndName);	
		},"json");
	}else{
		checkError(getError());	
		if(storageMode=="13"){
			alertMsg.warn("该卡不可读，不能作为空白/成品新卡出入库！");
		}else{
			alertMsg.warn("该卡不可读，视作废卡，请手动输入信息！");
			$("select",$stockTypeItem).val("3");
		}
	}
}

//删除信息
function deleteItem(obj){
	var $this = $(obj);
	var param = $this.attr("param");
	if($("input[name='checkedInfoBy"+param+"']:checked").length < 1){
		 alertMsg.warn("您未选择数据！")
		 return false;
	 }
	$("select[name='cardCodeBy"+param+"']").each(function(index,item){
		var valueSelected = $(item).val();
		if(valueSelected){
			$(item).find("option[value='"+valueSelected+"']").attr("selected",true);
		}
	});
	$("select[name='cardTypeBy"+param+"']").each(function(index,item){
		
		var valueSelected = $(item).val();
		if(valueSelected){
			$(item).find("option[value='"+valueSelected+"']").attr("selected",true);
		}
	});
	$("select[name='stockTypeBy"+param+"']").each(function(index,item){
			
			var valueSelected = $(item).val();
			if(valueSelected){
				$(item).find("option[value='"+valueSelected+"']").attr("selected",true);
			}
	});
	$("input[name='cardNoBy"+param+"']").each(function(index,item){
		
		var citizenCardNo = $(item).val();
		if(citizenCardNo){
			$(item).attr("value",citizenCardNo);
		}
	});
	$("input[name='cardIsReadBy"+param+"']").each(function(index,item){
		
		var cardIsRead = $(item).val();
		if(cardIsRead){
			$(item).attr("value",cardIsRead);
		}
	});
	
	/*$("input[name='empReceivedInfoChecked']:checked").each(function(n,item){
		var checkedId = $(item).val();
		console.log("checkedId==>"+checkedId);
		$("#returnCardInfoTable tr:eq("+(parseInt(checkedId)-1)+")").remove();
	});*/
	var checkedItems = $("input[name='checkedInfoBy"+param+"']:checked");
	var checkedLength = checkedItems.size();
	for(var i=0;i<checkedLength;i++){
		var checkedId = $(checkedItems[checkedLength-1-i]).val();
		$("#tdInfoBy"+param+" tr:eq("+(parseInt(checkedId)-1)+")").remove();
	}
	
	
	var currentHtml = "";
	$("#tdInfoBy"+param).find("tr").each(function(n,item){
	//	$(item).find("td").eq(0).find("input[name='checkedInfoBy"+param+"']").val(n+1);
	//	$(item).find("td").eq(1).html(n+1);	
		//卡产品代码
		var $cardCodeItem = $(item).find("td").eq(2).find("select");
		//卡类型下拉选
		var $typeItem = $(item).find("td").eq(3).find("select");
		//卡号选项
		var $citizenCardNoItem = $(item).find("td").eq(4).find("input");
		//库存卡类型下拉选
		var $stockTypeItem = $(item).find("td").eq(5).find("select");
		//隐藏的卡是否读取选项
		var $cardIsRead= $(item).find("td").eq(6).find("input");
		//转换成init之前得形式
		currentHtml +=  "<tr id='table'"+(n+1)+">"
						+"<td><input name='checkedInfoBy"+param+"' onclick='test(this)' value='"+(n+1)+"' type='checkbox'></td>"
						+"<td>"+(n+1)+"</td>"
						+"<td>"+$cardCodeItem.parent().html()+"</td>"
						+"<td>"+$typeItem.parent().html()+"</td>"
						+"<td>"+$citizenCardNoItem.parent().html()+"</td>"
						+"<td>"+$stockTypeItem.parent().html()+"</td>"
						+"<td style='display:none;'>"+$cardIsRead.parent().html()+"</td>"
						+"</tr>"
		
		
	})
	$("#tdInfoBy"+param).html("");
	console.log("currentHtml==>"+currentHtml);
	$("#tdInfoBy"+param).html(currentHtml);
	var $task = $("#tableInfoBy"+param);
	initUI($task);
}

function isRepeat(arr) {
    var hash = {};
    for(var i in arr) {
        if(hash[arr[i]]) {
            return true;
        }
        // 不存在该元素，则赋值为true，可以赋任意值，相应的修改if判断条件即可
        hash[arr[i]] = true;
    }
    return false;
}

function editCheckBox(obj){
	//如果是空白卡,废卡，归还卡片，盘盈入库，则需要输入卡号。
	var $this = $(obj);
	var param = $this.attr("param");
	console.log("param==>"+param);
	var flag = true;
	var storageMode = $("#storageModeBy"+param).val();
	console.log("storageMode==>"+storageMode);
	var arr=[];
	$("#tdInfoBy"+param+" tr").each(function(index,item){
		console.log("index==>"+index);
		var cardPCode = $(item).find("td:eq(2) select").val();
		var cardType = $(item).find("td:eq(3) select").val();
		var $inputCitizenNo = $(item).find("td:eq(4) input[name='cardNoBy"+param+"']");
		var citizenCardNo = $inputCitizenNo.val();
		var stockType = $(item).find("td:eq(5) select").val();
		var cardIsRead = $(item).find("td:eq(6) input").val();
		if(!citizenCardNo){
			//如果是不可识别，默认输入"未知"
			alertMsg.warn("请确认读取或输入，序号【"+(index+1)+"】的【卡号】");
			flag = false;
			return false;
		}
		if(citizenCardNo){
			var regu = /^[1-9][0-9]{11}$/;
			if(!regu.test(citizenCardNo)){
				alertMsg.warn("请输入序号【"+(index+1)+"】正确的市民卡号");
				flag = false;
				return false;
			}
			arr.push(citizenCardNo);
		}
		/*if(!cardPCode){
			alertMsg.warn("请输入序号【"+(index+1)+"】的【卡产品】");
			flag = false;
			return false;
		}
		if(!cardType){
			alertMsg.warn("请输入序号【"+(index+1)+"】的【卡类型】");
			flag = false;
			return false;
		}*/
		if(!stockType){
			//如果是不可识别，默认输入"未知"
			alertMsg.warn("请输入序号【"+(index+1)+"】的【分类标注】选项");
			flag = false;
			return false;
		}
		if(!cardIsRead){
			console.log("cardIsRead==>"+cardIsRead);
			if(storageMode=="13"){
				alertMsg.warn("序号【"+(index+1)+"】的卡片必须要读取！");
				flag = false;
				return false;
			}else{
				//查询该卡的信息
				$.ajaxSettings.async = false;
				$.post("inventorymanagement/queryCardInfoByCardNo",{"citizenCardNo":citizenCardNo},function(json){
					var obj = json.cardAndCustInfo;
					console.log("obj==>"+obj);
					if(!obj){
						alertMsg.warn("查不到该卡的信息，请联系管理员！不能作出入库操作");
				//		$("select",$cardPCodeItem).html(contentb);
				//		$("select",$cardTypeCodeItem).html(contenta);	
						$inputCitizenNo.val("");
						flag = false;
						return false;
					}
					var activeUser = json.activeUser;
					var currentBranchNo = activeUser.branchNo;
					var cardPcode = obj.cardPcode;
					var cardPName = obj.cardPName;
					var physicTypeCode = obj.physicTypeCode;
					var typeName = obj.typeName;
					var cardStatus = obj.cardStatus;
					var cardPosition = obj.cardPosition;
					var lastBranchNo = obj.lastBranchNo;
					var stockTypeByQuery = "";
					//新卡或废卡
					if(cardStatus=="0"&&obj.taskType){
						stockTypeByQuery = obj.taskType;
					}else{
						stockTypeByQuery = "3";
					}
					if("15"==storageMode){
						if("0"==cardStatus){
							alertMsg.warn("该卡是空白或成品卡的新卡，不能作为废卡上缴出入库操作！");
							$inputCitizenNo.val("");
							flag = false;
							return false;
						}
						if(!"2"==cardPosition){
							alertMsg.warn("该卡位置信息有误，请联系管理员！不能作出入库操作");
							$inputCitizenNo.val("");
							flag = false;
							return false;
						}else if(currentBranchNo!=lastBranchNo){
							//查询该卡的网点，与先操作员是否一致
							alertMsg.warn("该卡位置信息有误，请联系管理员！不能作出入库操作");
							$inputCitizenNo.val("");
							flag = false;
							return false;
						}
					}
					if("06"==storageMode){
						if(currentBranchNo!=lastBranchNo){
							//查询该卡的网点，与先操作员是否一致
							alertMsg.warn("该卡位置信息有误，请联系管理员！不能作出入库操作");
							flag = false;
							return false;
						}
						if("3"!=cardPosition){
							alertMsg.warn("卡信息有误，请联系管理员！不能作出入库操作！");
							flag = false;
							return false;
						}
						if(stockTypeByQuery!=stockType){
							alertMsg.warn("您输入的分类备注信息有误，请确认！");
							$(item).find("td:eq(5) select").val("");
							flag = false;
							return false;
						}
					}
			//		$("select",$cardPCodeItem).val(cardPcode);
			//		$("select",$cardTypeCodeItem).val(physicTypeCode);
			//		$("select",$stockTypeItem).val(stockType);
				},"json");
			}
			if(!flag){
				return flag;
			}
		}
	});
	if(isRepeat(arr)){
		alertMsg.warn("有重复卡号，请确认！");
		flag=false;
	}
	return flag;
}



function getInventoryInfo(json){
	var content = "";
	var list = json.list;
	if(list.length==0){
		content+="<tr><td colspan='8' align='center' >没有查询到相关信息</td></tr>"
	}else{
		for(var i=0;i<list.length;i++){
			var detailLinkHtml = "--";
			var param = encodeURI(list[i].cardpCode+"#"+list[i].cardpName+"#"+list[i].physicTypeCode+"#"+list[i].physicTypeName+"#"
						+list[i].cardStockType+"#"+list[i].stockPosition+"#"+list[i].stockPositionName+"#"+list[i].branchNo
						+"#"+list[i].branchName);
			if(list[i].currNum>0){
				detailLinkHtml = "<a class='linkStyle' href='inventoryQueryOfAmountAtBranch/queryDetailInvCardInfo' weight='900' height='500' target='dialog' rel='详细信息' param='"+param+"'>MORE……</a>";
			}
			content+="<tr align='center'>"
				     +"<td>"+[i+1]+"</td>"
				     +"<td>"+list[i].stockPositionName+"</td>"
				     +"<td>"+list[i].branchName+"</td>"
				     +"<td>"+list[i].cardpName+"</td>"
				     +"<td>"+list[i].physicTypeName+"</td>"
				     +"<td>"+list[i].cardStockTypeName+"</td>"
				     +"<td>"+list[i].currNum+"</td>"
				     +"<td>"+detailLinkHtml+"</td>"
				     +"</tr>" 	    
		}
	}
	$("#queryInventoryTable").html(content);
	var $p = $("#queryInventoryInfo");
	initUI($p);
}

function getIncomingAndOutgoingInfo(json){
	var content = "";
	var list = json.list||"";
	if(list.length==0){
		content+="<tr><td colspan='8' align='center' >没有查询到相关信息</td></tr>"
	}else{
		for(var i=0;i<list.length;i++){
		//	var value=list[i].taskNo+"#"+list[i].amount+"#"+list[i].cardPName+"#"+list[i].cardPCode;
		//	console.log("value===>"+value);
		//	var dateString = getDate(list[i].applyDate);
			//alert("checkBox-value==>"+value);
			var recordDate = list[i].recordDate.substring(0,4)+"-"+list[i].recordDate.substring(4);
			content+="<tr align='center'>"
				     +"<td>"+[i+1]+"</td>"
				     +"<td>"+list[i].branchName+"</td>"
				     +"<td>"+list[i].branchNo+"</td>"
				     +"<td>"+list[i].cardPname+"</td>"
				     +"<td>"+list[i].physicTypeName+"</td>"
				     +"<td>"+recordDate+"</td>"
				     +"<td>"+list[i].inComeAmount+"</td>"
				     +"<td>"+list[i].outAmount+"</td>"
				     +"</tr>" 	    
		}
	}
	$("#queryIncomeTable").html(content);
	var $p = $("#queryIncomeInfo");
	initUI($p);
}

function checkQuantity(obj){ 
	var $this = $(obj);
	var quantity = $this.parent().parent().prev().find("div").html();
	var stockQuantity = parseInt(quantity);
	/* if(quantity){
		stockQuantity = 
	} */
//	console.log("inpuvalue==>"+stockQuantity);
	var applyQuantityString = $this.val();
	if(applyQuantityString){
		if(!/^\d+$/.test(applyQuantityString)){
			alertMsg.warn("请输入整数数字！");
		}
	}
	var applyQuantity = parseInt(applyQuantityString);
//	console.log("applyQuantity==>"+applyQuantity);
	if(applyQuantity>stockQuantity){
		$("input[name='quantityCompareFlag']").val("false");
		alertMsg.warn("请求的数量不能大于库存数量，请重新输入！");
	}else{
		$("input[name='quantityCompareFlag']").val("true");
	}
}

function removeClass(){
	$("input[name='receivedQuantity']").each(function(index,item){
		var $item = $(item);
		$item.removeClass("requiredQuantityFlag");
	});
}

function checkQuantityBeforeSubmit(){
	var objArray = new Array();
	var flag = true;
	var cardPCode = $("select[name='receiveBlankCardClassify']").val();
	if(!cardPCode){
		alertMsg.warn("【卡产品】：不能为空！请选择！");
		flag=false;
		return false;
	}
	$("input[name='receivedQuantity']").each(function(index,item){
		var $item = $(item);
		var quantity = $item.val();
		if(quantity && parseInt(quantity)>0){
			$("input[name='isInput']").val("yes");
			var quantityFlag = $item.parent().parent().next().next().find("input[name='quantityCompareFlag']").val();
			if(quantityFlag=="false"){
				alertMsg.warn("请求的数量不能大于库存数量，请重新输入！");
				$item.addClass("requiredQuantityFlag");
				$("#empReceiveBlank").removeClass("validRequired");
				flag = false;
				return false;
			}
		}	
	});
	var isInputQuantity = $("input[name='isInput']").val();
	console.log("isInputQuantity==>"+isInputQuantity);
	if(isInputQuantity=="no"){
		alertMsg.warn("请输入请求数量，如不需要请退出！");
		$("#empReceiveBlank").removeClass("validRequired");
		flag = false;
		return false;
	}
	if(flag){
		$("#empReceiveBlank").addClass("validRequired");
	}
	//增加领取员工号的验证
	var empNo = $("#empReceiveBlank").val();
	var branchNo = $("#branchNoByEmpReceiveBlank").val();
	console.log("empNo==>"+empNo);
	if(empNo==""||empNo==null){
		alertMsg.warn("【领用员工编号】：不能为空！请输入！");
		flag=false;
		return false;
	}else{
		$.ajaxSettings.async = false;
		$.post("inventorymanagement/checkEmp",{empNo:empNo,branchNo:branchNo},function(json){
			var checkEmpResult = json.checkResult;
			if(!checkEmpResult){
				alertMsg.warn("请输入正确的员工号");
				flag=false;
			}
		},"json");
		$.ajaxSettings.async = true;
	}
	return flag;
}

function addFileList(json){
	if(json.statusCode==DWZ.statusCode.error){
		navTabAjaxDone(json)
	}else{
		var companyName = json.companyName;
		var filePathList = json.filePathList;
		var $tbody_tr = $("#tbodyByReturnFile").find("tr");
		var addHtml = "";
		var originalHtml = "";
		var currentHtml = "";
		var no = $tbody_tr.length;
		for(var j=0;j<filePathList.length;j++){
			addHtml += "<tr>"
				+"<td><input name='returnFileInfo' onclick='test(this)' value='"+($tbody_tr.length+j+1)+"' type='checkbox'></td>"
				+"<td>"+($tbody_tr.length+j+1)+"</td>"
				+"<td><input name='fileSourcePathToImport' value='"+filePathList[j]+"' readonly='readonly' size='100'/></td>"
				+"<td><input name='companyNameByInventory' value='"+companyName+"' readonly='readonly'/></td>"
			  +"</tr>";
		}
		
		//如果是第一次添加项目
		if($tbody_tr.length==0){
			currentHtml = addHtml;
		}
		if($tbody_tr.length>0){
			//判断是否有文件加入重复
			
			
			$.each($tbody_tr,function(index,item){
				//获取每个Td的内容
				var $td = $(item).find("td");
				var $td0 = $td.eq(0).children();
				var $td1 = $td.eq(1).children();
				var $td2 = $td.eq(2).children();
				var $td3 = $td.eq(3).children();
				var tdHtml= "<td>"+$td0.html()+"</td>"
							+"<td>"+$td1.html()+"</td>"
							+"<td>"+$td2.html()+"</td>"
							+"<td>"+$td3.html()+"</td>";
				originalHtml += "<tr>"+tdHtml+"</tr>";
			});
			currentHtml = originalHtml + addHtml;
			
		}
		$("#tbodyByReturnFile").html("");
		$("#tbodyByReturnFile").html(currentHtml);
		var $p = $("#tableInfoByReturnFile");
		initUI($p);
	}
}

function deleteReturnFile(obj){
	//查询是否被选中
	var $this = $(obj);
	//文件名称的数组，卡商数组；
	var fileNameArray;
	var companyNameArray;
	if($("input[name='returnFileInfo']:checked").length < 1){
		 alertMsg.warn("您未选择数据！")
		 return false;
	}
	//删除选项
	var checkedItems = $("input[name='returnFileInfo']:checked");
	var checkedLength = checkedItems.size();
	for(var i=0;i<checkedLength;i++){
		var checkedId = $(checkedItems[checkedLength-1-i]).val();
		//该行的文件名，该行的供应商
		var $tr = $("#tbodyByReturnFile tr:eq("+(parseInt(checkedId)-1)+")");
		var $td_file = $tr.find("td").eq(2);
		var $td_company = $tr.find("td").eq(3);
		var fileFullPath = $td_file.find("input[name='fileSourcePathToImport']").val();
		if(!fileNameArray){
			fileNameArray = fileFullPath.substring((fileFullPath.lastIndexOf("\\")+1));
		}else{
			fileNameArray = fileNameArray + "#" + fileFullPath.substring((fileFullPath.lastIndexOf("\\")+1));
		}
		if(!companyNameArray){
			companyNameArray = $td_company.find("input[name='companyNameByInventory']").val();
		}else{
			companyNameArray = companyNameArray + "#" + $td_company.find("input[name='companyNameByInventory']").val();
		}
		$tr.remove();
	}
	console.log("fileNameArray==>"+fileNameArray);
	console.log("companyNameArray==>"+companyNameArray);
	//重新排序
	var $tr = $("#tbodyByReturnFile").find("tr");
	var trLength = $tr.length;
	if(trLength>0){
		$.each($tr,function(index,item){
			var $td = $(item).find("td");
			$td.eq(0).children().find("input").attr("value",(index+1));
			$td.eq(1).children().html((index+1));
		});
		
		var $p = $("#tableInfoByReturnFile");
		initUI($p);
	}
	
	
	//删除工程路径下的文件
	var options = {"companyNameArray":companyNameArray,"fileNameArray":fileNameArray};
	$.ajax({
		 type:"POST",
		 url:"inventoryMagOfReturnFileImport/deleteFileList",
		 data:options,
		 dataType:"json",
		 cache: false,
		 success:navTabAjaxDone,
		 error: DWZ.ajaxError	 
	 });
}

function checkReturnFileRepeat(){
	var flag = true;
	var $tr = $("#tbodyByReturnFile").find("tr");
	var filePath = "";
	var filePaths = $("input[name='filePathByReturnCard']").val();
	if(!filePaths){
		alertMsg.warn("请选择要导入得文件！");
		flag = false;
		return flag;
	}
	var companyCode = $("select[name='makeCardCompanyByInventory']").val();
	if(!companyCode){
		alertMsg.warn("请选择制卡商！");
		flag = false;
		return flag;
	}
	var company = $("select[name='makeCardCompanyByInventory'] option[value='"+companyCode+"']").text();
	var filePathArray ;
	var fileNameArray = new Array();
	if(filePaths.indexOf(",")>0){
		filePathArray = filePaths.split(",");
		$.each(filePathArray,function(index,item){
			var lastIndex = item.lastIndexOf("\\");
			var fileName = item.substring((lastIndex+1));
			console.log("fileName==>"+fileName);
			fileNameArray.push(fileName);
		})
	}else{
		var fileName = filePaths.substring((filePaths.lastIndexOf("\\")+1));
		console.log("fileName==>"+fileName);
		fileNameArray.push(fileName);
	}
	if(fileNameArray.length>0 && company){
		$.each($tr,function(index,item){
			var toCompareFile = $(item).find("input[name='fileSourcePathToImport']").val();
			var toCompareFileName = toCompareFile.substring((toCompareFile.lastIndexOf("\\")+1));
			var toCompareCompany = $(item).find("input[name='companyNameByInventory']").val();
			console.log("toCompareFileName==>"+toCompareFileName);
			console.log("toCompareCompany==>"+toCompareCompany);
			if($.inArray(toCompareFileName, fileNameArray)>=0 && company==toCompareCompany){
				alertMsg.warn("请不要导入重复的文件！");
				flag = false;
				return false;
			}
		})
	}
	if(!flag){
		return false;
	}

	var formData1 = new FormData(document.getElementById( "addFile" ));
	 $.ajax({
		 type:"POST",
		 url:"inventoryMagOfReturnFileImport/addFileList",
		 data:formData1,
		 processData : false,
		 dataType:"json",
		 contentType : false ,
		 traditional:true,
		 cache: false,
		 success:addFileList,
		 error: DWZ.ajaxError	 
	 });

	return false;
};

function getDetailInvCardInfo(json){
	var branchName = json.branchName;
	var stockPositionName = json.stockPositionName;
	var cardPName = json.cardPName;
	var physicTypeName = json.physicTypeName;
	var quantity = json.quantity;
	var currentDate = json.currentDate;
	var citizenCardNoList = json.citizenCardNoList;
	var contentHtml = "";
	$("input[name='branchNameByQueryInv']").val(branchName);
	$("input[name='physicTypeByQueryInv']").val(physicTypeName);
	$("input[name='stockPositionByQueryInv']").val(stockPositionName);
	$("input[name='cardPNameByQueryInv']").val(cardPName);
	$("input[name='quantityByQueryInv']").val(quantity);
	$("input[name='dateByQueryInv']").val(currentDate);
	
	for(var i=0;i<citizenCardNoList.length;i++){
		contentHtml += "<tr>"
						+"<td>"+(i+1)+"</td>"
						+"<td>"+citizenCardNoList[i]+"</td>"
						+"</tr>";
	}
	$("#tbodyInfoByQuryInv").html(contentHtml);
	var $p = $("#tableInfoByQuryInv");
	initUI($p);
}

function printTableInfo(obj){
	var $this = $(obj);
	var theadContent = "";
	var table_div_id = $this.attr("url");
	var tableName = $this.attr("name");
	//编辑表格，传递参数到后台
	var $thead = $("#"+table_div_id+" table thead");
	var $tbody = $("#"+table_div_id+" table tbody");
	console.log("$tbody==>"+$tbody.html());
	
	//获取thead的内容
	var $th_arr = $("tr th",$thead);
	var th_size = $th_arr.length;
	$th_arr.each(function(index,item){
		var $item = $(item);
		var content = $item.children().html();
		if(index==0){
			theadContent=content;
		}else{
			theadContent = theadContent+"#"+content;
		}
	});
	
	//获取tbody是否有内容，先判断tr的个数，再判断td的个数
	var $tbodyTr_arr = $("tr",$tbody);
	if(!$tbodyTr_arr){
		alertMsg.warn("清单内容为空！");
		return false;
	}
	if($tbodyTr_arr.length==1){
		var $tbodyTr_td_arr = $tbodyTr_arr.find("td").not("[style='display: none']");
		if(th_size>$tbodyTr_td_arr.length){
			alertMsg.warn("清单内容为空！");
			return false;
		}
	}	
	
	//获取内容，组装对象，传递到后台
	// 获取表头 theadContent
	
	// 获取表内容
	var tbodyArray = new Array();
	
	$tbodyTr_arr.each(function(index,item){
		var $item_tr = $(item);
		var $item_tr_td = $item_tr.find("td").not("[style='display: none']");
	//	console.log("$item_tr_td==>"+$item_tr_td.length);
		var tdContent = "";
		$item_tr_td.each(function(index_td,item_td){
			var $item_td = $(item_td);
			var td_content;
			//查询td下面是否还有子节点,如果有子节点
			var $otherHtml = $item_td.children();
			if($otherHtml.children().length==0){
				td_content = $item_td.children().html();
				console.log("tdContent1["+index_td+"]==>"+td_content);
			}else{
				var tagName = $otherHtml.children().prop("nodeName");
				console.log("tagName==>"+tagName);
				if(tagName=="A"){
					td_content = $otherHtml.children().html();
				}
				if(tagName=="INPUT"){
					td_content = $otherHtml.children().val();
				}
				console.log("tdContent2==>"+td_content);
			}
			if(index_td==0){
				tdContent=td_content;
			}else{
				tdContent = tdContent+"#"+td_content;
			}
		});
		tbodyArray.push(tdContent);
	});

	 var description = ""; 
	 for(var i in tbodyArray){ 
	 var property=tbodyArray[i]; 
	 description+=i+" = "+property+"\n"; 
	 }  
	console.log("td==>"+description);
	var tableData = {"theadContent":theadContent,"tdContent[]":tbodyArray,"tableName":tableName};
	$.post("inventorymanagement/createTableList",tableData,printViewPageAjaxDone,"json");
}

function getRequestAndReturnInfo(json){
	var list = json.requestInfoList;
	var content = "";
	if(list.length==0){
		content+="<tr><td colspan='8' align='center' >未查询到数据</td></tr>"
	}
	for(var i=0;i<list.length;i++){
		content += "<tr align='center'>"
		     +"<td>"+[i+1]+"</td>"
		     +"<td>"+list[i].branchNo+"</td>"
		     +"<td>"+list[i].storageNo+"</td>"
		     +"<td>"+list[i].storageDesc+"</td>"
		     +"<td>"+list[i].regDate+"</td>"
		     +"<td>"+list[i].cardPName+"</td>"
		     +"<td>"+list[i].amount+"</td>"
		     +"<td>"+list[i].userNo+"</td>"
		     +"<td>"+list[i].userName+"</td>"
		     +"</tr>" 	    
	}
	$("#queryRequestAndReturnTable").html(content);
	var $p = $("#queryRequestAndReturnInfoByEmp");
	initUI($p);
}





